# Maintainer: Luca Weiss <luca@lucaweiss.eu>
# Contributor: Antoni Aloy <aaloytorrens@gmail.com>
pkgname=lomiri-content-hub
pkgver=2.0.0
pkgrel=0
pkgdesc="Content sharing/picking infrastructure and service, designed to allow apps to securely and efficiently exchange content"
url="https://gitlab.com/ubports/development/core/lomiri-content-hub"
arch="all !armhf" # blocked by lomiri-ui-toolkit-dev
license="GPL-3.0-only AND LGPL-3.0-only"
depends_dev="
	gsettings-qt-dev
	libapparmor-dev
	libnih-dev
	libnotify-dev
	lomiri-app-launch-dev
	lomiri-download-manager-dev
	lomiri-ui-toolkit-dev
	qt5-qtdeclarative-dev
	"
makedepends="
	$depends_dev
	cmake
	cmake-extras
	doxygen
	graphviz
	gtest-dev
	libapparmor
	qt5-qttools-dev
	samurai
	"
checkdepends="
	dbus-test-runner
	gmock
	xvfb-run
	"
source="https://gitlab.com/ubports/development/core/lomiri-content-hub/-/archive/$pkgver/lomiri-content-hub-$pkgver.tar.gz
	0001-Use-qdoc-qt5.patch
	0002-Use-qmlplugindump-qt5.patch
	"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		-DWerror=OFF
	cmake --build build
}

check() {
	# Some app_hub_communication_* tests require some custom dbus extension
	# (GetConnectionAppArmorSecurityContext).
	xvfb-run ctest --test-dir build --output-on-failure \
		-E 'app_hub_communication_store_migration|app_hub_communication_transfer|app_hub_communication_handler'
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Remove files for testing only
	# https://gitlab.com/ubports/development/core/lomiri-content-hub/-/blob/main/debian/lomiri-content-hub-testability.install
	rm "$pkgdir"/usr/bin/lomiri-content-hub-test*
	rm "$pkgdir"/usr/share/lomiri-content-hub/peers/lomiri-content-hub-test*
	rm "$pkgdir"/usr/share/applications/lomiri-content-hub-test*
	rm -r "$pkgdir"/usr/share/lomiri-content-hub/testability/data
	rm "$pkgdir"/usr/share/icons/hicolor/512x512/apps/lomiri-content-hub-test*
}

sha512sums="
9c54177eb8736bed7779856855dea27dd7cbde378180cfc9c3cc6cff29106c48745c2f069b24506d340672da1bdfacba0f59f7ebce3141ba5157b5e6c1c7bae5  lomiri-content-hub-2.0.0.tar.gz
825cd2c0ec784b60caf969037fa511e9db64bc88fef01057181598e88c95cffb4f0f8f2454927df34aadac8543ef499b3a1bbbe15688dad356eec0bbb9df3074  0001-Use-qdoc-qt5.patch
00e46300e3461d055db41eafa5507d3ed7771c9f2faa74c11f9219948cc4904d45034b39cc9ef755df9a1229ef2fe3aee925d39b1f7ef47d49dd4129322d541a  0002-Use-qmlplugindump-qt5.patch
"
